# -*- coding: utf-8 -*-
# @Time : 2025/6/24 上午9:45
# @Author : cc 
# @Email : liuchenchen@starmerx.com
# @Project : my-tools
# @Desc : 功能描述

def image_to_text_paddle(image):
    from paddleocr import PaddleOCR
    import cv2
    if isinstance(image, str):
        image = cv2.imread(image)

    ocr = PaddleOCR()
    print(image)
    result = ocr.predict(image)
    print(result)
    return "\n".join(result[0].get("rec_texts")) if result else None


def image_to_text_tesseract(image):
    import pytesseract
    text = pytesseract.image_to_string(image, lang='chi_sim')
    return text


if __name__ == '__main__':
    import cv2

    txt = image_to_text_paddle(cv2.imread('a.png'))
    # txt2 = image_to_text_tesseract(Image.open('a.png'))
    # print(txt2)
    print(txt)
